package com.youdianstar.app.util


import android.app.Activity
import android.app.Dialog
import android.graphics.Bitmap
import android.graphics.drawable.BitmapDrawable
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.EditText
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.size.Scale
import com.youdianstar.app.common.ConfigKey
import com.youdianstar.app.R
import com.youdianstar.app.common.entity.SheetData
import com.youdianstar.app.common.ex.setThrottleListener
import com.youdianstar.app.common.util.FileUtil
import com.youdianstar.app.common.util.ScreenUtil
import com.youdianstar.app.common.util.StrUtil
import com.youdianstar.app.common.util.ToastUtil
import com.youdianstar.app.common.util.Tool
import com.youdianstar.app.common.util.dialog.DialogUtil
import com.youdianstar.app.common.widget.*
import com.youdianstar.app.common.widget.adapter.BottomSheetAdapter
import com.youdianstar.app.adapter.IndustryAdapter
import com.youdianstar.app.entity.OpIndustry


/**
 * File: AppDialogUtil
 * Author: 82149 Create: 2021/10/26 15:27
 * Changes (from 2021/10/26)
 * --------------------------------------------------
 * description:
 * ---------------------------------------------------
 *
 */
class AppDialogUtil : DialogUtil() {
    companion object {

        val instance by lazy { AppDialogUtil() }

    }


    /**
     * OTP 提示弹框
     *
     * @param context view
     */
    fun showOTPNotify(context: Activity, textContent: String?,textConfirm: String?, confirm: ((View) -> Unit) = {}) {
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_otp, null)
        val dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, true, rootView)
        val tvContent = rootView.findViewById<TextView>(R.id.dialog_tv_content)
        textContent?.let {
            tvContent.text = it
        }
        val btnConfirm = rootView.findViewById<TextView>(R.id.bt_ok)
        textConfirm?.let {
            btnConfirm.text = it
        }
        btnConfirm.setOnClickListener {
            dialog?.dismiss()
            confirm.invoke(it)
        }
        helper?.adjustSizeGravity(dialog, (ScreenUtil.getScreenSize(context).x * 0.8).toInt(), 0, Gravity.CENTER)
        dialog?.show()
    }


    /**
     * 编辑弹框:昵称/邮箱/其他
     *
     * @param context
     * @param title    标题data
     * @param edtType 1 :Nick name ; 2: Receipt email
     */
    fun showEditDialog(
        context: Activity, title: String,hintText: String?=null,
        defaultName:String?=null,
        edtType:Int = 0,
        leftAction: (() -> Unit) = { }, rightAction: ((String) -> Unit) = { },
        left: String? = null, right: String? = null
    ): Dialog {
        cleanDialog()
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_edit, null)
        dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)
        val tvTitle = rootView.findViewById<TextView>(R.id.tv_title)
        val editText = rootView.findViewById<SearchEditText>(R.id.edit_msg)
        val tvLeft = rootView.findViewById<TextView>(R.id.tv_Left)
        val tvRight = rootView.findViewById<TextView>(R.id.tv_Right)

        tvRight.setOnClickListener {
            val inputStr = editText.text.toString().trim()
            if (StrUtil.isEmpty(inputStr)){
                if (edtType == 2)
                    ToastUtil.show(context,context.getString(R.string.toast_requiredEmail))
                return@setOnClickListener
            }
            if (edtType ==2 && !StrUtil.emailFormat(inputStr)){
                ToastUtil.show(context,context.getString(R.string.toast_validEmail))
                return@setOnClickListener
            }
            try {
                hideInputKeyboard(context, editText)
                dialog?.dismiss()
                rightAction(inputStr)
            } catch (_: Exception) {
            }
        }
        tvLeft.setOnClickListener {
            hideInputKeyboard(context, editText)
            dialog?.dismiss()
            leftAction()
        }

        if (!StrUtil.isEmpty(title)) {
            tvTitle.visibility = View.VISIBLE
            tvTitle.text = title
        }
        defaultName?.let {
            editText.setText(it)
        }

        hintText?.let {
            editText.hint = it
        }

        left?.let {
            tvLeft.text = it
        }
        right?.let {
            tvRight.text = it
        }
        helper?.adjustSizeGravity(dialog, (ScreenUtil.getScreenSize(context).x * 0.92).toInt(), 0, Gravity.CENTER)
        showDialog()
        return dialog!!
    }


    /**
     * 选择性别弹框
     *
     * @param context 上下文
     */
    fun showGenderDialog(context: Activity, data: List<String>, defaultP : Int = -1,selectAction: ((Int) -> Unit) = { }) {
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_gender_list, null)
        val dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)
        val rcyList = rootView.findViewById<RecyclerView>(R.id.rcy_data)
        rcyList.layoutManager = LinearLayoutManager(context)
        var selectIndex = -1
        val list = ArrayList<SheetData>()
        data.forEach {
            list.add(SheetData(0,it,true))
        }
        val adapter = BottomSheetAdapter(context = context,list, SheetCheckHelper(object :CheckHelper.HandleStateChange{
            override fun stateChange(holder: RecyclerView.ViewHolder, check: Boolean) {
                val box = holder.itemView.findViewById<ImageView>(R.id.sheet_item_box)
                box.isSelected = check
            }

            override fun clickWhich(position: Int) {
                selectIndex = position
            }
        },rcyList,defaultP))
        rcyList.adapter = adapter

        val btnLeft = rootView.findViewById<TextView>(R.id.tv_Left)
        btnLeft.setOnClickListener {
            dialog?.dismiss()
        }
        val btnRight = rootView.findViewById<TextView>(R.id.tv_Right)
        btnRight.setOnClickListener {
            dialog?.dismiss()
            selectAction(selectIndex)
        }
        helper?.adjustSizeGravity(dialog, (ScreenUtil.getScreenSize(context).x * 0.92).toInt(), 0, Gravity.CENTER)
        dialog?.show()
    }

    /**
     * 编辑邮箱弹框
     * @param context 上下文
     */
    fun showEditEmailDialog(context: Activity, listener: com.youdianstar.app.support.imp.IProfileEditListener, editCallback : com.youdianstar.app.support.imp.IOnEditListener) :Dialog?{
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_edit_email, null)
        val dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)
        val tvTitle = rootView.findViewById<TextView>(R.id.tv_title)
        val btnLeft = rootView.findViewById<TextView>(R.id.tv_Left)
        val btnRight = rootView.findViewById<TextView>(R.id.tv_Right)

        val btnSend = rootView.findViewById<TextView>(R.id.btn_sendOtp)
        val editOtp = rootView.findViewById<EditText>(R.id.edt_otp)
        val editEmail = rootView.findViewById<SearchEditText>(R.id.edit_email)

        tvTitle.text = context.getString(R.string.login_email)
        btnLeft.setOnClickListener {
            dialog?.dismiss()
        }
        btnRight.setOnClickListener {
            val emailStr = editEmail.text.toString()
            if (StrUtil.isEmpty(emailStr) || !StrUtil.emailFormat(emailStr)){
                ToastUtil.show(context,context.getString(R.string.toast_validEmail))
                return@setOnClickListener
            }
            val otpStr = editOtp.text.toString()
            if (StrUtil.isEmpty(otpStr)){
                ToastUtil.show(context,context.getString(R.string.toast_validCode))
                return@setOnClickListener
            }
            dialog?.dismiss()
            editCallback.onEditAccount(account = emailStr,code = "",msgCode = otpStr)
        }
        listener.setCountView(btnSend)


        btnSend.setOnClickListener {
            val emailStr = editEmail.text.toString()
            if (StrUtil.isEmpty(emailStr) || !StrUtil.emailFormat(emailStr)){
                ToastUtil.show(context,context.getString(R.string.toast_validEmail))
                return@setOnClickListener
            }
            listener.getOtpAction(emailStr,"")
        }

        helper?.adjustSizeGravity(dialog, (ScreenUtil.getScreenSize(context).x * 0.96).toInt(), 0, Gravity.CENTER)
        dialog?.show()
        return dialog
    }

    /**
     * 编辑手机号弹框
     * @param context 上下文
     */
    fun showEditPhoneDialog(context: Activity, listener: com.youdianstar.app.support.imp.IProfileEditListener, editCallback : com.youdianstar.app.support.imp.IOnEditListener) :Dialog?{
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_edit_phone, null)
        val dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)
        val tvTitle = rootView.findViewById<TextView>(R.id.tv_title)
        val btnLeft = rootView.findViewById<TextView>(R.id.tv_Left)
        val btnRight = rootView.findViewById<TextView>(R.id.tv_Right)

        val tvCode = rootView.findViewById<TextView>(R.id.tv_phoneCode)
        val btnSend = rootView.findViewById<TextView>(R.id.btn_sendOtp)
        val editOtp = rootView.findViewById<EditText>(R.id.edt_otp)
        val editPhone = rootView.findViewById<SearchEditText>(R.id.edit_phone)

        tvTitle.text = context.getString(R.string.login_phoneNumber)
        btnLeft.setOnClickListener {
            dialog?.dismiss()
        }
        btnRight.setOnClickListener {
            val countryCode = listener.getCountryCode()
            if (StrUtil.isEmpty(countryCode)){
                ToastUtil.show(context,context.getString(R.string.toast_areaCode))
                return@setOnClickListener
            }

            val phoneStr = editPhone.text.toString()
            if (StrUtil.isEmpty(phoneStr) || phoneStr.length<4){
                ToastUtil.show(context,context.getString(R.string.toast_validPhone))
                return@setOnClickListener
            }

            val otpStr = editOtp.text.toString()
            if (StrUtil.isEmpty(otpStr)){
                ToastUtil.show(context,context.getString(R.string.toast_validCode))
                return@setOnClickListener
            }

            dialog?.dismiss()
            editCallback.onEditAccount(account = phoneStr,code = countryCode, msgCode = otpStr)
        }
        listener.setCountView(btnSend)
        listener.setCountryView(tvCode)

        tvCode.setOnClickListener {
            listener.selectCountryAction()
        }

        btnSend.setOnClickListener {
            val phoneStr = editPhone.text.toString()
            if (StrUtil.isEmpty(phoneStr) || phoneStr.length<4){
                ToastUtil.show(context,context.getString(R.string.toast_validPhone))
                return@setOnClickListener
            }
            listener.getOtpAction(phoneStr,"phone")
        }

        helper?.adjustSizeGravity(dialog, (ScreenUtil.getScreenSize(context).x * 0.96).toInt(), 0, Gravity.CENTER)
        dialog?.show()
        return dialog
    }

    /**
     * 查看大图
     *
     * @param context
     */
    fun showImageCheckDialog(context: Activity , url :String): Dialog?{
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_image_larget, null)
        val dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, true, rootView)
        val ivBack = rootView.findViewById<ImageView>(R.id.iv_back)
        val ivPic = rootView.findViewById<ZoomTouchView>(R.id.imageView)
        ivBack.setOnClickListener {
            dialog?.dismiss()
        }

        ivPic.load(url){
            scale(Scale.FILL)
            placeholder(R.drawable.ic_img_picker_default)
            error(R.drawable.ic_img_picker_default)
        }
        helper?.adjustSizeGravity(dialog, ScreenUtil.getScreenSize(context).x, ScreenUtil.getScreenSize(context).y, Gravity.CENTER)
        dialog?.show()
        return dialog
    }

    /**
     * 选择语言 弹框
     * @param context 上下文
     */
    fun showBoxSelectDialog(context: Activity, txTitle: String, data: List<String>,defaultP : Int = 0, selectAction: ((Int) -> Unit) = { }) {
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_box_list, null)
        dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)

        val tvTitle = rootView.findViewById<TextView>(R.id.tv_title)
        if (!StrUtil.isEmpty(txTitle))
            tvTitle.text = txTitle
        val rcyList = rootView.findViewById<RecyclerView>(R.id.rcy_data)
        rcyList.layoutManager = LinearLayoutManager(context)
        var selectIndex = 0
        val list = ArrayList<SheetData>()
        data.forEach {
            list.add(SheetData(0, it, true))
        }
        val adapter = BottomSheetAdapter(context = context, list, SheetCheckHelper(object : CheckHelper.HandleStateChange {
            override fun stateChange(holder: RecyclerView.ViewHolder, check: Boolean) {
                val box = holder.itemView.findViewById<ImageView>(R.id.sheet_item_box)
                box.isSelected = check
            }

            override fun clickWhich(position: Int) {
                selectIndex = position
            }
        },rcyList,defaultP))
        rcyList.adapter = adapter

        val btnLeft = rootView.findViewById<TextView>(R.id.tv_Left)
        btnLeft.setOnClickListener {
            dialog?.dismiss()
        }
        val btnRight = rootView.findViewById<TextView>(R.id.tv_Right)
        btnRight.setOnClickListener {
            dialog?.dismiss()
            selectAction(selectIndex)
        }
        helper?.adjustSizeGravity(dialog, (ScreenUtil.getScreenSize(context).x * 0.92).toInt(), 0, Gravity.CENTER)
        dialog?.show()
    }


    /**
     * Contact Us
     *
     * @param context activity
     * @param phoneStr PhoneNumber
     */
    fun showContactDialog(context: Activity,
                          phoneStr : String? =null,emailStr : String? =null,wechatLink : String? =null,
                          callAction: (() -> Unit) = { }, emailAction: (() -> Unit) = { },) : Dialog?{
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_contract, null)
        dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)

        val ivBack = rootView.findViewById<ImageView>(R.id.iv_back)
        val ivClose = rootView.findViewById<ImageView>(R.id.iv_close)
        val clMethod = rootView.findViewById<ConstraintLayout>(R.id.cl_method_container)
        val clQrcode = rootView.findViewById<LinearLayout>(R.id.cl_qr_container)
        val tvCall = rootView.findViewById<TextView>(R.id.tv_phone_num)
        val tvEmail = rootView.findViewById<TextView>(R.id.tv_email_num)
        val ivCopy = rootView.findViewById<ImageView>(R.id.iv_copy)
        val tvWechatLink = rootView.findViewById<TextView>(R.id.tv_view_num)
        val ivQrcode = rootView.findViewById<ImageView>(R.id.iv_qr)
        val tvQrcodeSave = rootView.findViewById<TextView>(R.id.tv_view_save)

        ivClose.setThrottleListener {
            dialog?.dismiss()
        }

        ivBack.setThrottleListener {
            clQrcode.visibility = View.GONE
            clMethod.visibility = View.VISIBLE
            ivBack.visibility = View.INVISIBLE
        }

        if (StrUtil.isEmpty(phoneStr)){
            tvCall.text = "--"
        }else{
            Tool.setUnderLine(context,tvCall,phoneStr,R.color.color_default)
        }
        if (StrUtil.isEmpty(emailStr)){
            tvEmail.text = "--"
            ivCopy.visibility = View.INVISIBLE
        }else{
            tvEmail.text = emailStr
            ivCopy.visibility = View.VISIBLE
        }

        tvCall.setThrottleListener {
            callAction.invoke()
        }

        tvEmail.setThrottleListener {
            //emailAction.invoke() //2401 不调用系统分享了
        }

        ivCopy.setThrottleListener {
            if (!StrUtil.isEmpty(emailStr)){
                Tool.copy(context,emailStr)
                ToastUtil.show(context,context.getString(R.string.invite_copied))
            }
        }

        if (StrUtil.isEmpty(wechatLink)){
            tvWechatLink.text = "--"
            tvQrcodeSave.visibility = View.INVISIBLE
        }else{
            tvWechatLink.visibility = View.VISIBLE
            tvQrcodeSave.visibility = View.VISIBLE
            Tool.setUnderLine(context,tvWechatLink,context.getString(R.string.help_qrCode),R.color.color_default)
            Tool.setUnderLine(context,tvQrcodeSave,context.getString(R.string.help_saveQR),R.color.color_default)
        }

        var qrBitmap :Bitmap? =null
        tvWechatLink.setThrottleListener {
            if (!StrUtil.isEmpty(wechatLink)){
                val host = DataAppManager.instance.getConfig(ConfigKey.FILE_HOST)
                val linkUrl = if (wechatLink!!.startsWith("http")) wechatLink else host + wechatLink
                if (FileUtil.isImageUrl(linkUrl)){
                    ivQrcode.load(linkUrl){
                        error(R.drawable.ic_img_picker_default)
                    }
                }else{
                    qrBitmap= QrCodeUtil.createQRCodeBitmap(wechatLink,1800,1800)
                    ivQrcode.setImageBitmap(qrBitmap)
                }
                clMethod.visibility = View.GONE
                clQrcode.visibility = View.VISIBLE
                ivBack.visibility = View.VISIBLE
            }
        }

        tvQrcodeSave.setThrottleListener {
            if (null==qrBitmap){
                val drawable = ivQrcode.getDrawable()
                qrBitmap = (drawable as? BitmapDrawable)?.bitmap
            }
            FileUtil.saveBitmapToImage(context,qrBitmap)
            ToastUtil.show(context,context.getString(R.string.public_success))
        }

        ivBack.visibility = View.INVISIBLE
        clQrcode.visibility = View.GONE
        clMethod.visibility = View.VISIBLE
        helper?.adjustSizeGravity(dialog, ScreenUtil.getScreenSize(context).x, 0, Gravity.BOTTOM)
        dialog?.show()
        return dialog
    }


    /**
     * 搜索结果弹框
     *
     * @param context
     * @param msg     data
     */
    fun showSearchResultDialog(context: Activity,
                         title: String, msg: String,
                         leftAction: (() -> Unit) = { },
                         rightAction: (() -> Unit) = { },
                         left: String? = null,
                         right: String? = null
    ): Dialog {
        cleanDialog()
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_search_result, null)
        val resultDialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)
        val tvTitle = rootView.findViewById<TextView>(R.id.tv_title)
        val tvMsg = rootView.findViewById<TextView>(R.id.tv_content)
        val tvLeft = rootView.findViewById<TextView>(R.id.tv_Left)
        val tvRight = rootView.findViewById<TextView>(R.id.tv_Right)
        val tvVertical = rootView.findViewById<TextView>(R.id.tv_vertical)

        tvLeft.setOnClickListener {
            //resultDialog?.dismiss()
            try {
                leftAction()
            } catch (_: Exception) {
            }
        }
        tvRight.setOnClickListener {
            //resultDialog?.dismiss()
            rightAction()
        }

        if (!StrUtil.isEmpty(title)) {
            tvTitle.visibility = View.VISIBLE
            tvTitle.text = title
        } else
            tvTitle.visibility = View.GONE
        tvMsg.text = msg
        left?.let {
            tvLeft.text = it
        }
        right?.let {
            tvRight.text = it
        }
        helper?.adjustSizeGravity(resultDialog, (ScreenUtil.getScreenSize(context).x * 0.86).toInt(), 0, Gravity.CENTER)
        resultDialog?.show()
        return resultDialog!!
    }


    /**
     * 商户中心页面
     * --选择行业
     *
     * @param data Coupon list
     */
    fun showIndustrySelectSheet(context: Activity, data: MutableList<OpIndustry>, selectAction: ((Int) -> Unit) = { }): Dialog? {
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.sheet_op_industries, null)
        val dialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)
        val ivClose = rootView.findViewById<ImageView>(R.id.ic_cancel)
        val rcyList = rootView.findViewById<RecyclerView>(R.id.rcy_data)

        rcyList.layoutManager = LinearLayoutManager(context)
        val adapter = IndustryAdapter(context = context, dataList = data, object :IndustryAdapter.ItemSelectListener{
            override fun onItemAction(index: Int) {
                selectAction.invoke(index)
                dialog?.dismiss()
            }
        })
        rcyList.adapter = adapter

        ivClose.setThrottleListener {
            dialog?.dismiss()
        }

        helper?.adjustSizeGravity(dialog, ScreenUtil.getScreenSize(context).x, ScreenUtil.getScreenSize(context).y, Gravity.BOTTOM)
        dialog?.show()
        return dialog
    }

    private var hintDialog : Dialog? =null

    /**
     * 租借弹出提示
     * @param msg 文本提示
     */
    fun showRentingHintDialog(context: Activity, msg:String){
        cleanHintDialog()
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_renting_hint, null)
        hintDialog = helper?.createBaseDialog(context, R.style.AlertToastStyle, false, rootView)
        val tvMsg = rootView.findViewById<TextView>(R.id.tv_hint)
        tvMsg.text = msg

        helper?.adjustSizeGravity(hintDialog,
            (ScreenUtil.getScreenSize(context).x * 0.76).toInt(), 0, Gravity.CENTER)
        hintDialog?.show()
    }

    fun cleanHintDialog(){
        hintDialog?.dismiss()
        hintDialog = null
    }

    /**
     * 打开定位
     *
     * @param context activity
     */
    fun showLocationSwitchDialog(context: Activity,switchAction: (() -> Unit) = { }): Dialog?{
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_location, null)
        val switchDialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)

        val tvCancel = rootView.findViewById<TextView>(R.id.tv_Left)
        val tvConfirm = rootView.findViewById<TextView>(R.id.tv_Right)

        tvCancel.setThrottleListener {
            switchDialog?.dismiss()
        }

        tvConfirm.setThrottleListener {
            switchDialog?.dismiss()
            switchAction.invoke()
        }

        helper?.adjustSizeGravity(switchDialog, (ScreenUtil.getScreenSize(context).x * 0.86).toInt(), 0, Gravity.CENTER)
        switchDialog?.show()
        return switchDialog
    }


    /**
     * 显示二次确认
     *
     * @param title 标题
     * @param msg 文本
     */
    fun showVersionUpdateDialog(context: Activity,
                                title: String, msg: String,
                                left: String? = null,
                                right: String? = null,
                                rightAction: (() -> Unit) = { },
                                isForce:Boolean = false
    ): Dialog {
        val rootView: View = LayoutInflater.from(context).inflate(R.layout.layout_dialog_notify, null)
        val updateDialog = helper?.createBaseDialog(context, R.style.AlertDialogStyle, false, rootView)
        val tvTitle = rootView.findViewById<TextView>(R.id.tv_title)
        val tvMsg = rootView.findViewById<TextView>(R.id.tx_content)
        val tvLeft = rootView.findViewById<TextView>(R.id.tv_Left)
        val tvRight = rootView.findViewById<TextView>(R.id.tv_Right)
        val tvVertical = rootView.findViewById<TextView>(R.id.tv_vertical)

        tvLeft.setOnClickListener {
            updateDialog?.dismiss()
        }
        tvRight.setOnClickListener {
            updateDialog?.dismiss()
            rightAction()
        }

        if (!StrUtil.isEmpty(title)) {
            tvTitle.visibility = View.VISIBLE
            tvTitle.text = title
        } else
            tvTitle.visibility = View.GONE
        tvMsg.text = msg
        tvVertical.visibility = if (!isForce) View.VISIBLE else View.GONE
        tvLeft.visibility = if (!isForce) View.VISIBLE else View.GONE
        tvRight.visibility = View.VISIBLE
        left?.let {
            tvLeft.text = it
        }
        right?.let {
            tvRight.text = it
        }
        helper?.adjustSizeGravity(updateDialog, (ScreenUtil.getScreenSize(context).x * 0.86).toInt(), 0, Gravity.CENTER)
        updateDialog?.show()
        return updateDialog!!
    }

}